package com.china.great.system.controller;

import com.china.great.common.common.CommonResultUtil;
import com.china.great.system.entity.SystemUser;
import com.china.great.system.service.SystemUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Liu HongYang
 * @DateTime: 2020/7/13 11:17 下午
 * @Description: TODO
 */
@RestController
@Api("登陆")
@RequestMapping("/system")
public class LoginController {

    @Autowired
    private SystemUserService systemUserService;

    @PostMapping(value = "/login")
    @ApiOperation(value = "登陆", notes = "登陆成功返回token,登陆之前请先注册账号")
    public Object login(@RequestBody SystemUser user){
        String response = systemUserService.login(user.getUsername(), user.getPassword());
        return CommonResultUtil.success(response);
    }

}
